/*
 * JSUtil.java - ScriptME
 * 
 * Copyright (c) 2009 Cesar Henriques <cesar at alttab.com.ar>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Based on FESI Project
 * 
 * Contributors:
 * 	Jean-Marc Lugrin - initial API and implementation
 * 	Cesar Henriques <cesar at alttab.com.ar> - J2ME Porting and Extensions
 */
package org.scriptme.ecmascript.jslib;

import org.scriptme.ecmascript.interpreter.Evaluator;

/**
 * Abstract class used for interfacing the FESI EcmaScript interpreter with Java
 * code. Contains the static utility functions, as the evaluator factory and
 * object factory.
 */
abstract public class JSUtil {

	/**
	 * Create a new evaluator, with no extension loaded.
	 * 
	 * @return The global object of the created evaluator.
	 * 
	 * @throws JSException
	 *             the JS exception
	 * 
	 * @exception JSException
	 *                For any error during initialization
	 */
	static public JSGlobalObject makeEvaluator() throws JSException {
		return org.scriptme.ecmascript.data.JSWrapper.makeEvaluator();
	}

	/**
	 * Create a new evaluator, with specfied extensions loaded.
	 * 
	 * @param extensions
	 *            the extensions
	 * 
	 * @return The global object of the created evaluator.
	 * 
	 * @throws JSException
	 *             the JS exception
	 * 
	 * @exception JSException
	 *                For any error during initialization
	 */
	static public JSGlobalObject makeEvaluator(String[] extensions)
			throws JSException {
		return org.scriptme.ecmascript.data.JSWrapper.makeEvaluator(extensions);
	}

	/**
	 * Return the version identifier of the interpreter.
	 * 
	 * @return the version
	 */
	public static String getVersion() {
		return Evaluator.getVersion();
	}

	/**
	 * Return the welcome text (including copyright and version) of the
	 * interpreter (as two lines).
	 * 
	 * @return the welcome text
	 */
	public static String getWelcomeText() {
		return Evaluator.getWelcomeText();
	}
}
